package com.gem.eolane.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gem.eolane.entity.User;
import com.gem.eolane.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class UserService extends ServiceImpl<UserMapper, User> {

    @Autowired
    private UserMapper userMapper;

    //插入user
    public void insertUser(String userName,String password,String phoneNumber,Integer sex,String company,String mail){
        userMapper.insertUser(userName,password,phoneNumber,sex,company,mail);
    }

    //查询总用户记录数
    public int userTotal(String name){
      return userMapper.userTotal(name);
    };

    //查询总页数
    public int userTotalPage(String name){
        return ((userMapper.userTotal(name)-1)/5 + 1);
    }

    //查询当前页的记录
    public List<User> currentList(String userName,int currentPage){
       return userMapper.currentList(userName,(currentPage-1)*5);
    }
    //逻辑删除user
    public void banUser(Integer id,Integer delIdent){
        userMapper.banUser(id,delIdent);
    }

    //根据邮箱查询对象
    public boolean findUserByPhoneNumber(String phoneNumber){
        if(userMapper.findUserByPhoneNumber(phoneNumber)!= null){
            return true;
        }else{
            return false;
        }
    }

    //===============liuhui=============


    //根据手机号获取对象
    public User findQueryUser(String phoneNumber){
        return userMapper.queryUser(phoneNumber);

    }
    //修改用户信息
    public void findupdateUser(User user){
        userMapper.updateUser(user);
    }
    //用户密码修改
    public void findUptadePwd(User user){
        userMapper.upadatePwd(user);
    }
}
